@extends('front.layout')
@section('title','首页')
@section('head')
    <div class="nav">
        <ul class="nav_body">
            <li><a href="/" class="current">首页</a></li>
            <li><a href="/conf">名家讲堂</a></li>
            <li><a href="/expert">名家风采</a></li>
            <li><a href="/review">往期视频</a></li>
        </ul>
    </div>
@endsection
@section('content')
    <div class="main">
        <div class="index_top clearfix">
            <div class="index_left">
                <div class="index_left_bg"><img src="/assets/images/last_time_bg.jpg" /></div>
                <div class="index_left_body">
                    @if(isset($zVideo[0]))
                        <!--会议进行中-->
                        <input type="hidden" id="url" value="{{$zVideo[0]->url}}">
                        <?php $video=$zVideo[0]?>
                        <div class="meeting">
                            <a href="javascript:void(show2())">
                                <img src="/assets/images/online_classing.png" />
                            </a>
                        </div>
                    @elseif(isset($qVideo[0]))
                        <?php $video=$qVideo[0]?>
                        <div class="before" >
                            <div class="last_time" >
                                <span class="time1"></span>
                                <span class="time2"></span>
                                <span class="time3"></span>
                                <span class="time4"></span>
                            </div>
                            <a class="class_href" href="#"></a>
                        </div>
                    @elseif(isset($oVideos[0]))
                        <!--会议结束-->
                            <?php $video=$oVideos[0]?>
                        <div class="end_title">会议已结束</div>
                    @else
                            <?php $video=''?>
                        <div class="end_title">暂时没有会议</div>
                    @endif
                    <?php
                        if($video!='') {
                            include("./phpqrcode/phpqrcode.php");
                            function getQRcode($data, $outfile)
                            {
                                $Qrcode = new QRcode();
                                $Qrcode->png($data, $outfile, 'L', 10);//前两个参数：文字（二维码的内容） 输出路径
                            }

                            $data = $video->url;
                            $outfile = './assets/images/shouye.png';
                            getQRcode($data, $outfile);
                        }
                    ?>
                    @if(isset($qVideo[0])||isset($zVideo[0]))
                    <div class="left_share">
                        <span>分享到：</span>
                        <a href="javascript:void(show())"><img src="/assets/images/icon_weixin.jpg" /></a>
                    </div>
                    @endif
                </div>
            </div>
            <div class="index_right">
                <div class="title_box">专家介绍</div>
                <div class="index_right_list">
                    @if($video!='')
                    <?php $sum=0?>
                    @foreach($video->lecture as $v)
                        <?php $sum++?>
                        @if($sum<=2)
                        <div class="index_right_ship clearfix">
                            <div class="index_right_img">
                                <a href="/expert/expert-info/{{$v->id}}"><img src="{{$v->thumb}}" /></a>
                            </div>
                            <div class="index_right_txt">
                                <p>专家: {{$v->name}}</p>
                                <p>职位: {{$v->job_name}}</p>
                                <p>医院: {{$v->hospital}}</p>
                                <p><a href="/expert/expert-info/{{$v->id}}">详细>></a></p>
                            </div>
                        </div>
                        @endif
                    @endforeach
                    @endif
                    <div class="index_right_more"><a href="/expert">more+</a></div>
                </div>
            </div>
        </div>
        <div class="review">
            <div class="title_box">精彩回顾</div>
            <div class="review_list">
                <div class="one_line clearfix">
                    @if($video!='')
                        <?php
                        $count=0;
                        ?>
                    @foreach($oVideos as $v)
                            <?php $count++ ?>
                        @if($count<3)
                            <div class="review_ship ">
                                <div class="review_ship_img">
                                    <a href="/review/review-info/{{$v->id}}">
                                        <img src="{{$v->thumb}}" />
                                    </a>
                                </div>
                                <div class="review_ship_txt">
                                    <div class="review_ship_title break"><a href="/review/review-info/{{$v->id}}">{{$v->title}}</a></div>
                                    <div class="review_ship_intro clearfix">
                                        <div class="review_ship_left">
                                            <p>主持：<a href="/expert/expert-info/{{$v->Lecture[0]->id}}">{{$v->Lecture[0]->name}}</a></p>
                                            <p>日期：<span class="txt_999">{{$v->begin_time}}</span></p>
                                        </div>
                                        <div class="review_ship_right">
                                            <a class="info_btn" href="/review/review-info/{{$v->id}}">查看详情</a>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        @elseif($count==3)
                            <div class="review_ship mar_0">
                                <div class="review_ship_img">
                                    <a href="/review/review-info/{{$v->id}}">
                                        <img src="{{$v->thumb}}" />
                                    </a>
                                </div>
                                <div class="review_ship_txt">
                                    <div class="review_ship_title break"><a href="/review/review-info/{{$v->id}}">{{$v->title}}</a></div>
                                    <div class="review_ship_intro clearfix">
                                        <div class="review_ship_left">
                                            <p>主持：<a href="/expert/expert-info/{{$v->Lecture[0]->id}}">{{$v->Lecture[0]->name}}</a></p>
                                            <p>日期：<span class="txt_999">{{$v->begin_time}}</span></p>
                                        </div>
                                        <div class="review_ship_right">
                                            <a class="info_btn" href="/review/review-info/{{$v->id}}">查看详情</a>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        @endif
                    @endforeach
                    @endif
                </div>
            </div>
        </div>
    </div>
    <!--微信分享弹窗-->
    <div class="shadow" id="shadow" style="display:none"></div>
    <div class="chat_pop" style="display:none" id="chat_pop">
        <div class="chat_pop_top"><a href="javascript:void(hide())" class="chat_pop_close"></a></div>
        <div class="chat_pop_body">
            <img src="/assets/images/shouye.png" />
            <p>使用微信扫一扫，并将网页分享给好友</p>
        </div>
    </div>
    <!-- 姓名输入弹出框 -->
    <div id="name_pop" class="export_pop" style="display:none">
        <div class="export_pop_top">
            <span>提示</span>
            <a href="javascript:hide2()" class="export_pop_close"></a>
        </div>
        <div class="export_pop_body">
            <div>请输入您的姓名：</div>
            <div class="export_name_input"><input id="nick_name" type="text" /></div>
            <div class="export_name_submit"><input type="button" class="btn blue_btn" value="确定" onclick="join_meeting()"/></div>
        </div>
    </div>
    <script>
        var time1 = document.querySelector(".time1");
        var time2 = document.querySelector(".time2");
        var time3 = document.querySelector(".time3");
        var time4 = document.querySelector(".time4");
        //获取截止时间的时间戳（单位毫秒）
        var inputTime = +new Date("<?php if(isset($qVideo[0])) echo ($qVideo[0]->begin_time)?>");
        var outTime = +new Date("<?php if(isset($zVideo[0])) echo ($zVideo[0]->end_time)?>");

        //我们先调用countDown函数，可以避免在打开界面后停一秒后才开始倒计时
        countDown();
        //定时器 每隔一秒变化一次
        setInterval(countDown, 1000);
        function countDown() {
            //获取当前时间的时间戳（单位毫秒）
            var nowTime = +new Date();
            //把剩余时间毫秒数转化为秒
            var times = (inputTime - nowTime) / 1000;
            var timess = (outTime - nowTime) / 1000;
            //计算小时数 转化为整数
            if(parseInt(times)>=0) {
                var d = parseInt(times / 60 / 60 / 24);
                //如果小时数小于 10，要变成 0 + 数字的形式 赋值给盒子
                time1.innerHTML = d;
                var h = parseInt(times / 60 / 60 % 24);
                //如果小时数小于 10，要变成 0 + 数字的形式 赋值给盒子
                time2.innerHTML = h < 10 ? "0" + h : h;
                //计算分钟数 转化为整数
                var m = parseInt(times / 60 % 60);
                //如果分钟数小于 10，要变成 0 + 数字的形式 赋值给盒子
                time3.innerHTML = m < 10 ? "0" + m : m;
                //计算描述 转化为整数
                var s = parseInt(times % 60);
                //如果秒钟数小于 10，要变成 0 + 数字的形式 赋值给盒子
                time4.innerHTML = s < 10 ? "0" + s : s;
                if(parseInt(times) == 0) location.reload(1);
            }
            if(parseInt(timess)==0) location.reload(1);
        }
    </script>
@endsection
